From: Florian Müllner Date: Wed, 10 Jul 2019 15:18:16 +0000 (+0200) Subject: userWidget: Handle non-square icons gracefully X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~839^2^2~98 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=5fc456d9d9413d8c5c87569dc9c57fc19d93c5f9;p=gnome-shell.git userWidget: Handle non-square icons gracefully We currently assume that user icons are square, which is the case when set by the users settings panel, but not enforced by AccountsService. Handle that case by moving the pixel size back to the actor and using an appropriate background-size style property of 'cover' (which means the smallest dimension of the image is scaled to fit the desired size). https://gitlab.gnome.org/GNOME/gnome-shell/issues/1144 --- diff --git a/js/ui/userWidget.js b/js/ui/userWidget.js index 232a5f181..a24f37a3f 100644 --- a/js/ui/userWidget.js +++ b/js/ui/userWidget.js @@ -46,9 +46,13 @@ var Avatar = class { if (iconFile) { this.actor.child = null; + let { scaleFactor } = St.ThemeContext.get_for_stage(global.stage); + this.actor.set_size( + this._iconSize * scaleFactor, + this._iconSize * scaleFactor); this.actor.style = ` background-image: url("${iconFile}"); - background-size: ${this._iconSize}px`; + background-size: cover;`; } else { this.actor.style = null; this.actor.child = new St.Icon({ icon_name: 'avatar-default-symbolic',